package com.ja.openchat.ui.contact;

import android.widget.CheckBox;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ja.openchat.R;
import com.ja.openchat.views.UserAvatarView;
import com.zy.openchat.core.model.contact.Section;
import com.zy.openchat.core.model.contact.SectionInfo;
import com.zy.openchat.core.model.message.ChatInfo;


import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class GroupHomeListAdapter extends BaseSectionQuickAdapter<Section, BaseViewHolder> {
    public GroupHomeListAdapter(@Nullable List<Section> data) {
        super(R.layout.adapter_section_contact_list, data);
        setNormalLayout(R.layout.adapter_contact_list_home);
    }

    @Override
    protected void convertHeader(@NotNull BaseViewHolder helper, @NotNull Section section) {
        helper.setText(R.id.iv_title, ((SectionInfo) section.getObject()).title);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, Section section) {
        ChatInfo chat = (ChatInfo) section.getObject();
        helper.setText(R.id.iv_title, chat.title);
        UserAvatarView avatarView = helper.getView(R.id.iv_icon);
        avatarView.setTextSize(17);
        avatarView.showGroup(chat);

        CheckBox check_box = helper.getView(R.id.check_box);
        check_box.setChecked(section.isChecked());
    }
}
